<script setup>
import { onMounted, computed, nextTick } from 'vue'
import { useUserStore } from '@/stores/user.js'
import { useRoute } from 'vue-router'
import Navbar from '@/components/Navbar.vue'

const userStore = useUserStore()
const route = useRoute()

const shouldShowNavbar = computed(() => {
  return route.path !== '/login'
})

onMounted(async () => {
  // 初始化用户状态
  userStore.initUserState()

  // 等待下一个tick，确保用户状态已经更新
  await nextTick()
})
</script>

<template>
  <div id="app">
    <router-view />
  </div>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin: 0;
  padding: 0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
</style>
